<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/25
 * Time: 10:02
 */

namespace Home\Controller;
use Think\Controller;
class UsermsgController extends Controller {
    public function index(){
        if(session('username')){
            $news=M();
            $count=$news->count();//获取表中数据的记录总数
            $page=new \Think\Page($count,10);
            $page->setConfig('header','<li class="rows">共<b>%TOTAL_ROW%</b>条记录 第
                    <b>%NOW_PAGE%</b>页/共<b>%TOTAL_PAGE%</b>页</li>');
            $page->setConfig('prev','上一页');
            $page->setConfig('next','下一页');
            $page->setConfig('end','末页');
            $page->setConfig('first','首页');
            $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');
            $page->lastSuffix=false;//设置最后一页不显示为总页数
            $show=$page->show();
            $sql="select uname,cnumber,idcard,uphone,money,paymoney FROM tp_user JOIN tp_cost where tp_user.uid=tp_cost.uid LIMIT ".$page->firstRow.','.$page->listRows;
            $data=$news->query($sql);
//            echo $news->getLastSql();
//            var_dump($data);
//            var_dump($page);
//            exit();
            $this->assign("data",$data);
            $this->assign('pages',$show);
            $this->display();
        }
        else{
            $this->error("您好，请先登录!",U('/Home/Login/index/'));
        }
    }
    public function select($uname,$cnumber){
        if(session('username')){
            redirect(U('/Home/Allmsg/index/',array('uname'=>$uname,'cnumber'=>$cnumber)));
        }else{
            redirect(U('/Home/Login/index/'),0,'重新登录');
        }
    }
}